layui.use(['table', 'jquery', 'layer'], function () {
    var table = layui.table,
        layer = layui.layer,
        $ = layui.jquery;

    var tableIns = table.render({
        elem: '#materialList', //绑定table id
        height: 'full-125',
        url: ctx + '/supplier/material_list',
        page: true,
        cellMinWidth: 80, // 单元格最小宽度
        toolbar: '#toolbarDemo',
        cols: [[ // 表头
            {type: 'checkbox'},
            {type: "numbers"},
            {title: "名称", field: "materialName"},
            {title: "编码", field: "materialNo"},
            {title: "单位", field: "materialUnit"},
            {
                title: "添加人", field: "empBean", templet: function (data) {
                    return data.empBean.empName;
                }
            },
            {title: "创建时间", field: "materialCreateDate"},
            {title: "更新时间", field: "materialUpdateDate"},
            {title: "操作", templet: "#materialListBar"}
        ]]
    })

    table.on('toolbar(materialFilter)', function (data) {
        if (data.event == "addMaterial") {
            openAddMaterialDialog();
        }
    })

    function openAddMaterialDialog() {
        layer.open({
            type: 2,
            title: "物料用例---添加物料用例",
            content: ctx + "/supplier/toAddOrUpdateMaterial",
            area: ['500px', '500px'],
            shadeClose: true,
            maxmin: true
        })
    }
})